package com.boarsoft.boar.entity;

import java.util.HashSet;
import java.util.Set;

/**
 * 
 * 
 * @author Mac_J
 *
 */
public abstract class AppInfo {
	/** 应用状态：0：停用，1：启用 */
	public static final short STATUS_NOUSE = 0;
	/** 应用状态：0：停用，1：启用 */
	public static final short STATUS_INUSE = 1;
	/** */
	public static final String HANDLER_DEFAULT = "macRpcAppHandler";

	/** 应用ID */
	protected String id;
	/** 应用编号，加版本才唯一 */
	protected String code;
	/**
	 * 应用在打包和部署方面的分类：<br/>
	 * 0：普通应用（需要导源码、打包编译、部署）<br/>
	 * 1：属于配置一类的应用（只需导源码，无需打包编译、部署、停机、启动、重启等动作）<br/>
	 * 2：属于配置一类的应用（只需导源码，可能需打包编译、部署，但无停机启动重启动作）<br/>
	 */
	protected short type;
	/** 应用版本 */
	protected String ver;
	/** 应用名称 */
	protected String name;
	/** 所属系统 */
	protected String projId;
	/** 应用状态：0：停用，1：启用 */
	protected short status = STATUS_NOUSE;
	/** 所属用户 */
	protected String user;
	/** 端口号 */
	protected int port;
	/** 库包相对与应用的位置 */
	protected String libPath;
	/** 应用在服务器上的部署用临时路径 */
	protected String tempPath = "/home/app/temp";
	/** 应用在服务器上的部署路径 */
	protected String deployPath = "/home/app/deploy";
	/** 应用描述 */
	protected String memo = "";
	/** 用于与这个应用交互实现管控的代理对象 */
	protected String handler = HANDLER_DEFAULT;
	/** 健康检查间隔 */
	private int interval;
	/** 健康检查重试次数 */
	private int retry;

	/** 停机构建码 */
	protected String shutdownCode;
	/** 启动构建码 */
	protected String startCode;
	/** 重启构建码 */
	protected String restartCode;
	/** 重新加载配置 */
	protected String reloadCode;

	/** 应用与节点的多对多关系 */
	private Set<ServerInfo> insts = new HashSet<ServerInfo>();
	/** 应用与库包的多对多关系 */
	private Set<LibInfo> libs = new HashSet<LibInfo>();
	/** 应用与配置文件的多对多关系 */
	private Set<FileInfo> files = new HashSet<FileInfo>();

	@Override
	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o instanceof AppInfo) {
			AppInfo a = (AppInfo) o;
			return id.equals(a.getId());
		}
		return false;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getVer() {
		return ver;
	}

	public void setVer(String ver) {
		this.ver = ver;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getProjId() {
		return projId;
	}

	public void setProjId(String projId) {
		this.projId = projId;
	}

	public short getStatus() {
		return status;
	}

	public void setStatus(short status) {
		this.status = status;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getLibPath() {
		return libPath;
	}

	public void setLibPath(String libPath) {
		this.libPath = libPath;
	}

	public String getDeployPath() {
		return deployPath;
	}

	public void setDeployPath(String deployPath) {
		this.deployPath = deployPath;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public String getShutdownCode() {
		return shutdownCode;
	}

	public void setShutdownCode(String shutdownCode) {
		this.shutdownCode = shutdownCode;
	}

	public String getStartCode() {
		return startCode;
	}

	public void setStartCode(String startCode) {
		this.startCode = startCode;
	}

	public String getRestartCode() {
		return restartCode;
	}

	public void setRestartCode(String restartCode) {
		this.restartCode = restartCode;
	}

	public Set<ServerInfo> getInsts() {
		return insts;
	}

	public void setInsts(Set<ServerInfo> insts) {
		this.insts = insts;
	}

	public Set<LibInfo> getLibs() {
		return libs;
	}

	public void setLibs(Set<LibInfo> libs) {
		this.libs = libs;
	}

	public Set<FileInfo> getFiles() {
		return files;
	}

	public void setFiles(Set<FileInfo> files) {
		this.files = files;
	}

	public String getTempPath() {
		return tempPath;
	}

	public void setTempPath(String tempPath) {
		this.tempPath = tempPath;
	}

	public short getType() {
		return type;
	}

	public void setType(short type) {
		this.type = type;
	}

	public String getHandler() {
		return handler;
	}

	public void setHandler(String handler) {
		this.handler = handler;
	}

	public String getReloadCode() {
		return reloadCode;
	}

	public void setReloadCode(String reloadCode) {
		this.reloadCode = reloadCode;
	}

	public int getInterval() {
		return interval;
	}

	public void setInterval(int interval) {
		this.interval = interval;
	}

	public int getRetry() {
		return retry;
	}

	public void setRetry(int retry) {
		this.retry = retry;
	}
}